package com.example.javalib;

import com.example.javalib.agencymode.HouseAgent;
import com.example.javalib.agencymode.HouseAgentSmart;
import com.example.javalib.agencymode.HouseOwner;
import com.example.javalib.agencymode.IRentHouse;
import com.example.testlib.Test;
import com.example.testlib.UtilsTestKt;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
import java.util.HashMap;
import java.util.Map;

public class JavaClass {
    public static void main(String[] args) {
        System.out.println("Hello Java World~");
        // 在 Java 类中调用 Kotlin 类的方法
        UtilsTestKt.printGoodMorning();
        // 在 Java 中调用 object 匿名内部类需要加上 INSTANCE
        Test.INSTANCE.say("今天是美好的");


        Map mapProxy = (Map) Proxy.newProxyInstance(
                HashMap.class.getClassLoader(),
                new Class[]{Map.class},
                new InvocationHandler() {
                    @Override
                    public Object invoke(Object o, Method method, Object[] objects) throws Throwable {
                        return null;
                    }
                }
        );


        HouseAgent agent = new HouseAgent(new HouseOwner());
        agent.visitHouse();
        agent.argueRent(300);
        agent.signAgreement();


        // Java 动态代理
//        IRentHouse smartAgent = new HouseAgentSmart(new HouseOwner()).getAccess();
//        smartAgent.visitHouse();
//        smartAgent.argueRent(400);
//        smartAgent.signAgreement();


    }


}